// Vuex状态管理
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

//状态数据,要设置全局访问的state对象
const state = {
    user: {
        user_id: null,
        user_age: null,
        user_name: null,
        user_pwd: null,
        user_role: null,
        user_image: null,
        user_phone: null,
    },
    musicUrl: {
        name: "",
        artist: "",
        url: "",
        lrc: "",
    }
};
const actions = {
    setUser(context, payload) {
        context.commit('setUser', payload);
    },
    setMusic(context, payload) {
        context.commit('setMusic', payload);
    },
};
const mutations = {
    setUser(state, payload) {
        this.state.user = payload;
    },
    setMusic(state, payload) {
        this.state.musicUrl = payload;
    },
};
const store = new Vuex.Store({
    state,
    actions,
    mutations
});
export default store;